//生成账目任务(steps步骤数组，job步骤名称，djid单据id，gs公司，wllx往来类型，wldx往来对象，zklx账款类型，zkje账款金额，yjje已结金额，zt状态，ywsj业务时间，ywdj业务单据，xm项目，ywlx业务类型，bsc办事处)
function jy_zmrw(steps,job,djid,gs,wllx,wldx,zklx,zkje,yjje,zt,ywsj,ywdj,xm,ywlx,bsc,wlxz){
    var rw={
        "step_name": job,
        "opt_type": 1,
        "datatable_id": "1886323389442822144",
        "args": "",
        "field_params": [{
            "value_from": 1,
            "field": "djid",
            "value": djid,
            "data_type": 1
        },{
            "value_from": 1,
            "field": "gs",
            "value": gs,
            "data_type": 1
        },{
          "value_from": 1,
          "field": "wllx",
          "value": wllx,
          "data_type": 1
      },{
            "value_from": 1,
            "field": "wldx",
            "value": wldx,
            "data_type": 1
        },{
            "value_from": 1,
            "field": "zklx",
            "value": zklx,
            "data_type": 1
        },{
            "value_from": 1,
            "field": "zkje",
            "value": zkje,
            "data_type": 1
        },{
            "value_from": 1,
            "field": "yjje",
            "value": yjje,
            "data_type": 1
        },{
            "value_from": 1,
            "field": "zt",
            "value": zt,
            "data_type": 1
        },{
            "value_from": 1,
            "field": "ywsj",
            "value": ywsj,
            "data_type": 1
        },{
          "value_from": 1,
          "field": "ywdj",
          "value": ywdj,
          "data_type": 1
        },{
          "value_from": 1,
          "field": "xm",
          "value": xm,
          "data_type": 1
        },{
          "value_from": 1,
          "field": "ywlx",
          "value": ywlx,
          "data_type": 1
        },{
          "value_from": 1,
          "field": "bsc",
          "value": bsc,
          "data_type": 1
        },{
          "value_from": 1,
          "field": "wlxz",
          "value": wlxz?wlxz:"",
          "data_type": 1
        }]
    }
    steps.push(rw);
    //steps=jy_xgwlje(steps,job,xm,gs,bsc,wldx,zklx,zkje)
    return steps;
  }
  //创建往来余额
  function jy_cjwlye(argsobj,xm,gs,bsc,wldxs,func){
    if(wldxs){
      var args={"steps":[]}
      var cond="a.:[xm]=? and a.:[gs]=? and a.:[bsc]=? and (";
      var values=[xm,gs,bsc];
      for(var i=0;i<wldxs.length;i++){
        cond+="(a.:[wldx]=? and a.:[zklx]=?)";
        if(i!=wldxs.length-1){
          cond+=" or ";
        }else{
          cond+=")";
        }
        values.push(wldxs[i].wldx);
        values.push(wldxs[i].zklx);
      }
      //查询往来对象余额是否存在，不存在则需要新建
      var args2 = {
        "datatable_id": "1914534321918578688",
        "search": "",
        "search_fields": [
          {
            "quick_search": true,
            "field": "wldx",
            "table": "a",
            "data_type": 1
          },
          {
            "quick_search": true,
            "field": "zklx",
            "table": "a",
            "data_type": 1
          }
        ],
        "advance_filters": {condition: cond, values: JSON.stringify(values)},
        "page": 1,
        "page_size": 20,
        "include": {} 
      }
      ycWindow.plugins.crud.Query(args2, (result) => {
        for(var i=0;i<wldxs.length;i++){
          //当前往来余额是否存在
          var exsit=false;
          for(var j=0;j<result.total;j++){
            if(wldxs[i].wldx==result.data[j].wldx&&wldxs[i].zklx==result.data[j].zklx){
              exsit=true;
            }
          }
          if(!exsit){
              args.steps.push({
                "step_name": "插入往来余额"+i,
                "opt_type": 1,
                "datatable_id": "1914534321918578688",
                "args": "",
                "field_params": [{
                    "value_from": 1,
                    "field": "xm",
                    "value": xm,
                    "data_type": 1
                  },{
                    "value_from": 1,
                    "field": "gs",
                    "value": gs,
                    "data_type": 1
                  },{
                    "value_from": 1,
                    "field": "bsc",
                    "value": bsc,
                    "data_type": 1
                  },{
                    "value_from": 1,
                    "field": "wldx",
                    "value": wldxs[i].wldx,
                    "data_type": 1
                  },{
                    "value_from": 1,
                    "field": "zklx",
                    "value": wldxs[i].zklx,
                    "data_type": 1
                  },{
                    "value_from": 1,
                    "field": "zkye",
                    "value": 0,
                    "data_type": 1
                  },{
                    "value_from": 1,
                    "field": "wllx",
                    "value": wldxs[i].wllx,
                    "data_type": 1
                  }]
            })
          }
        }
        ycWindow.plugins.crud.ExecJobs(args, (data) => {
            ycWindow.plugins.form.submitWithJobs("提交表单",1,{},argsobj, () => {
                func();
            }, (data) => {
                //检查字符串是否包含数组中的字符串
                if(tools_jczfc(data,["公司","钱包","没有匹配的数据"])){
                ycWindow.dom.opener.dom.showMsg("公司钱包余额不足", "error")
                }else if(tools_jczfc(data,["办事处","钱包","没有匹配的数据"])){
                ycWindow.dom.opener.dom.showMsg("办事处钱包余额不足", "error")
                }else if(tools_jczfc(data,["第三方","钱包","没有匹配的数据"])){
                ycWindow.dom.opener.dom.showMsg("第三方钱包余额不足", "error")
                }else if(tools_jczfc(data,["钱包","没有匹配的数据"])){
                ycWindow.dom.opener.dom.showMsg("钱包余额不足", "error")
                }
            })
        }, (data) => {
        })
      }, (data) => {
      })
    }
  }
  //修改往来金额
  function jy_xgwlje(steps,job,xm,gs,bsc,wldx,zklx,je){
    //查询往来对象金额
    var rw1={
      "step_name": "查询往来对象金额_"+job,
      "opt_type": 5,
      "query_args": {
        "datatable_id": "1914534321918578688",
        "search_fields": [
          {
            "field": "cast((a.:[zkye] + ("+je+")) as decimal(12,2)) as bghye",
            "table": "a",
            "data_type": 11
          }
        ],
        "advance_filters": {
          "condition": "a.:[xm]=? and a.:[gs]=? and a.:[bsc]=? and a.:[wldx]=? and a.:[zklx]=?",
          "values": JSON.stringify([xm,gs,bsc,wldx,zklx])
        }
      },
      "query_into": "往来对象金额_"+job
    };
    steps.push(rw1);
    //更新往来对象金额
    var rw2={
      "step_name": "更新往来对象金额_"+job,
      "opt_type": 4,
      "datatable_id": "1914534321918578688",
      "args": "往来对象金额_"+job+".id",
      "args_from": 3,
      "field_params": [
        {
          "value_from": 3,
          "field": "zkye",
          "value": "往来对象金额_"+job+".bghye",
          "data_type": 1
        },
        {
            "value_from": 1,
            "field": "rld",
            "value": "",
            "data_type": 1
          }
      ]
    };
    steps.push(rw2);
    return steps;
  }
  //批量生成钱包付款任务，参数(scdx收款往来对象,wldx付款往来对象,je金额,sj交易时间,djid单据id),jobname任务名称必填
  function jy_qbfk(steps,objs,jobname){
    objs.forEach((item,index) => {
      //查询收款对象钱包余额
      steps.push({
        "opt_type": 5,
        "query_args": {
          "advance_filters": {
            "condition": "a.:[wldx] = ?",
            "values": JSON.stringify([item.scdx])
          },
          "datatable_id": "1880859109138370560",
          "search_fields": [
            {
              "data_type": 2,
              "field": "qbye",
              "quick_search": false,
              "table": "a"
            },
            {
              "data_type": 11,
              "field": "cast((a.:[qbye]+ "+item.je+") as decimal(12,2)) as bghye",
              "quick_search": false,
              "table": ""
            }
          ]
        },
        "query_into": "办事处钱包"+jobname+index,
        "step_name": "查询办事处钱包余额"+jobname+index
      })
      //插入收款对象钱包变更明细
      steps.push({
        "args": "",
        "datatable_id": "1880859104839208960",
        "field_params": [
          {
            "data_type": 1,
            "field": "djid",
            "value": item.djid,
            "value_from": 1
          },
          {
            "data_type": 1,
            "field": "jyfx",
            "value": "汇入",
            "value_from": 1
          },
          {
            "data_type": 2,
            "field": "jyje",
            "value": item.je,
            "value_from": 1
          },
          {
            "data_type": 1,
            "field": "wldx",
            "value": item.scdx,
            "value_from": 1
          },
          {
            "data_type": 12,
            "field": "jyhye",
            "value": "办事处钱包"+jobname+index+".bghye",
            "value_from": 3
          },
          {
            "data_type": 2,
            "field": "jyqye",
            "value": "办事处钱包"+jobname+index+".qbye",
            "value_from": 3
          },
          {
            "data_type": 3,
            "field": "jysj",
            "value": item.sj,
            "value_from": 1
          }
        ],
        "opt_type": 1,
        "step_name": "插入办事处钱包变更明细"+jobname+index
      })
      //更新收款对象钱包余额
      steps.push(    {
        "args": "办事处钱包"+jobname+index+".id",
        "args_from": 3,
        "datatable_id": "1880859109138370560",
        "field_params": [
          {
            "data_type": 2,
            "field": "qbye",
            "value": "办事处钱包"+jobname+index+".bghye",
            "value_from": 3
          }
        ],
        "opt_type": 4,
        "step_name": "更新办事处钱包余额"+jobname+index
      })
      //查询主体公司钱包余额
      steps.push({
        "opt_type": 5,
        "query_args": {
          "advance_filters": {
            "condition": "a.:[wldx] = ? and (a.:[qbye]+ifnull(a.:[xyed],0) - "+item.je+")>=0",
            "values": JSON.stringify([item.wldx])
          },
          "datatable_id": "1880859109138370560",
          "search_fields": [
            {
              "data_type": 2,
              "field": "qbye",
              "quick_search": false,
              "table": "a"
            },
            {
              "data_type": 11,
              "field": "cast((a.:[qbye] - "+item.je+") as decimal(12,2)) as bghye",
              "quick_search": false,
              "table": ""
            }
          ]
        },
        "query_into": "主体公司钱包"+jobname+index,
        "step_name": "查询主体公司钱包余额"+jobname+index
      })
      //插入主体公司钱包变更明细
      steps.push({
        "args": "",
        "datatable_id": "1880859104839208960",
        "field_params": [
          {
            "data_type": 1,
            "field": "djid",
            "value": item.djid,
            "value_from": 1
          },
          {
            "data_type": 1,
            "field": "jyfx",
            "value": "汇出",
            "value_from": 1
          },
          {
            "data_type": 2,
            "field": "jyje",
            "value": item.je,
            "value_from": 1
          },
          {
            "data_type": 1,
            "field": "wldx",
            "value": item.wldx,
            "value_from": 1
          },
          {
            "data_type": 2,
            "field": "jyhye",
            "value": "主体公司钱包"+jobname+index+".bghye",
            "value_from": 3
          },
          {
            "data_type": 2,
            "field": "jyqye",
            "value": "主体公司钱包"+jobname+index+".qbye",
            "value_from": 3
          },
          {
            "data_type": 3,
            "field": "jysj",
            "value": item.sj,
            "value_from": 1
          }
        ],
        "opt_type": 1,
        "step_name": "插入主体公司钱包变更明细"+jobname+index
      })
      steps.push({
        "args": "主体公司钱包"+jobname+index+".id",
        "args_from": 3,
        "datatable_id": "1880859109138370560",
        "field_params": [
          {
            "data_type": 2,
            "field": "qbye",
            "value": "主体公司钱包"+jobname+index+".bghye",
            "value_from": 3
          }
        ],
        "opt_type": 4,
        "step_name": "更新主体公司钱包余额"+jobname+index
      })
    });
    return steps;
  }
  //钱包单个往来对象批量收付款，wldx往来对象，sj时间，obj交易明细数组(je金额，jyfx交易方向，djid单据ID)，jobname步骤名称
  function jy_qbdxsfk(steps,wldx,sj,objs,jobname){
    //钱包变更总额度
    var total=0;
    objs.forEach((item,index) => {
        //本次变更金额
        var je=parseFloat(item.je)?parseFloat(item.je):0;
        //如果是付款，那么金额需要为负数
        je=(item.jyfx=="付款"?-1*je:je);
        //计算余额变化总额度
        total+=je;
        //查询往来对象钱包余额
        steps.push({
            "opt_type": 5,
            "query_args": {
                "advance_filters": {
                "condition": "a.:[wldx] = ? and (a.:[qbye]+ifnull(a.:[xyed],0) + "+total+")>=0",
                "values": JSON.stringify([wldx])
                },
                "datatable_id": "1880859109138370560",
                "search_fields": [
                    {
                        "data_type": 2,
                        "field": "qbye",//原钱包余额
                        "quick_search": false,
                        "table": "a"
                    },
                    {
                      "data_type": 11,
                      "field": "cast((a.:[qbye]+ ("+total+")) as decimal(12,2)) as bghye",//变更后余额
                      "quick_search": false,
                      "table": ""
                    },
                    {
                      "data_type": 11,
                      "field": "cast((a.:[qbye]+ "+total+"-("+je+")) as decimal(12,2)) as bgqye",//变更前余额
                      "quick_search": false,
                      "table": ""
                    }
                ]
            },
            "query_into": "往来对象钱包"+jobname+index,
            "step_name": "查询往来对象钱包余额"+jobname+index
        })
        //插入钱包变更明细
        steps.push({
          "args": "",
          "datatable_id": "1880859104839208960",
          "field_params": [
            {
              "data_type": 1,
              "field": "djid",
              "value": item.djid,
              "value_from": 1
            },
            {
              "data_type": 1,
              "field": "jyfx",
              "value": item.jyfx,
              "value_from": 1
            },
            {
              "data_type": 2,
              "field": "jyje",
              "value": item.je,
              "value_from": 1
            },
            {
              "data_type": 1,
              "field": "wldx",
              "value": wldx,
              "value_from": 1
            },
            {
              "data_type": 2,
              "field": "jyhye",
              "value": "往来对象钱包"+jobname+index+".bghye",//变更后余额
              "value_from": 3
            },
            {
              "data_type": 2,
              "field": "jyqye",
              "value": "往来对象钱包"+jobname+index+".bgqye",//变更前余额
              "value_from": 3
            },
            {
              "data_type": 3,
              "field": "jysj",
              "value": sj,
              "value_from": 1
            }
          ],
          "opt_type": 1,
          "step_name": "插入往来对象钱包变更明细"+jobname+index
        })
      });
    //查询往来对象钱包余额
    steps.push({
        "opt_type": 5,
        "query_args": {
            "advance_filters": {
                "condition": "a.:[wldx] = ?",
                "values": JSON.stringify([wldx])
            },
            "datatable_id": "1880859109138370560",
            "search_fields": [
                {
                    "data_type": 2,
                    "field": "qbye",
                    "quick_search": false,
                    "table": "a"
                },
                {
                    "data_type": 11,
                    "field": "cast((a.:[qbye]+ ("+total+")) as decimal(12,2)) as bghye",
                    "quick_search": false,
                    "table": ""
                }
            ]
        },
        "query_into": "往来对象钱包"+jobname,
        "step_name": "查询往来对象钱包余额"+jobname
    })
    //更新收款对象钱包余额
    steps.push({
        "args": "往来对象钱包"+jobname+".id",
        "args_from": 3,
        "datatable_id": "1880859109138370560",
        "field_params": [
            {
            "data_type": 11,
            "field": "qbye",
            "value": "往来对象钱包"+jobname+".bghye",
            "value_from": 3
            }
        ],
        "opt_type": 4,
        "step_name": "更新往来对象钱包余额"+jobname
    })
      return steps;
  }
  //往来对象钱包占用(jobname步骤名称,steps步骤数组,wldx往来对象,je金额,djid单据id,djbh单据编号,ywlx业务类型,sj时间)
  function jy_qbzy(jobname,steps,wldx,je,djid,djbh,ywlx,sj){
    steps.push({
        "opt_type": 5,
        "query_args": {
          "advance_filters": {
            "condition": "a.:[wldx] = ? and (a.:[qbye]+ifnull(a.:[xyed],0)-ifnull(a.:[zyje],0)-"+je+">=0)",
            "values": JSON.stringify([wldx])
          },
          "datatable_id": "1880859109138370560",
          "search_fields": [
            {
              "data_type": 2,
              "field": "zyje",
              "quick_search": false,
              "table": "a"
            },
            {
              "data_type": 11,
              "field": "cast((ifnull(a.:[zyje],0) + "+je+") as decimal) as bghzyje",
              "quick_search": false,
              "table": ""
            }
          ]
        },
        "query_into": "办事处钱包"+jobname,
        "step_name": "查询办事处钱包占用金额"+jobname
    })
    steps.push({
        "args": "",
        "datatable_id": "1894256919367913472",
        "field_params": [
          {
            "data_type": 1,
            "field": "djid",
            "value": djid?djid:"提交表单",//如果单据id是空，那么从提交表单步骤中取值
            "value_from": djid?1:2//从提交表单步骤中取值的时候，需要设置为变量，枚举是2
          },
          {
            "data_type": 2,
            "field": "je",
            "value": je,
            "value_from": 1
          },
          {
            "data_type": 1,
            "field": "ywdj",
            "value": djbh,
            "value_from": 1
          },
          {
            "data_type": 1,
            "field": "wldx",
            "value": wldx,
            "value_from": 1
          },
          {
            "data_type": 1,
            "field": "ywlx",
            "value": ywlx,
            "value_from": 1
          },
          {
            "data_type": 3,
            "field": "sj",
            "value": sj,
            "value_from": 1
          }
        ],
        "opt_type": 1,
        "step_name": "插入办事处钱包占用明细"+jobname
    })
    steps.push(  {
        "args": "办事处钱包"+jobname+".id",
        "args_from": 3,
        "datatable_id": "1880859109138370560",
        "field_params": [
          {
            "data_type": 2,
            "field": "zyje",
            "value": "办事处钱包"+jobname+".bghzyje",
            "value_from": 3
          }
        ],
        "opt_type": 4,
        "step_name": "更新办事处钱包占用金额"+jobname
    })
    return steps;
  }
  //往来对象钱包占用释放(jobname步骤名称,steps步骤数组,wldx往来对象,je金额,djid单据id,djbh单据编号,ywlx业务类型,sj时间)
  function jy_qbzysf(jobname,steps,wldx,je,djid){
    steps.push(  {
        "opt_type": 5,
        "query_args": {
          "advance_filters": {
            "condition": "a.:[wldx] = ?",
            "values": JSON.stringify([wldx])
          },
          "datatable_id": "1880859109138370560",
          "search_fields": [
            {
              "data_type": 2,
              "field": "zyje",
              "quick_search": false,
              "table": "a"
            },
            {
              "data_type": 11,
              "field": "cast((ifnull(a.:[zyje],0) - "+je+") as decimal) as bghzyje",
              "quick_search": false,
              "table": ""
            }
          ]
        },
        "query_into": "办事处钱包"+jobname,
        "step_name": "查询办事处钱包占用金额和钱包余额"+jobname
    })
    steps.push({
        "opt_type": 5,
        "query_args": {
          "advance_filters": {
            "condition": "a.:[djid] = ?",
            "values": JSON.stringify([djid])
          },
          "datatable_id": "1894256919367913472",
          "search_fields": []
        },
        "query_into": "钱包占用明细"+jobname,
        "step_name": "查询办事处钱包占用明细"+jobname
    })
    steps.push({
        "args": "办事处钱包"+jobname+".id",
        "args_from": 3,
        "datatable_id": "1880859109138370560",
        "field_params": [
          {
            "data_type": 2,
            "field": "zyje",
            "value": "办事处钱包"+jobname+".bghzyje",
            "value_from": 3
          }
        ],
        "opt_type": 4,
        "step_name": "更新办事处钱包占用金额"+jobname
    })
    steps.push({
        "args": "钱包占用明细"+jobname+".id",
        "args_from": 3,
        "datatable_id": "1894256919367913472",
        "field_params": [],
        "opt_type": 2,
        "step_name": "删除办事处钱包占用明细"+jobname
    })
    return steps;
  }
  //新增担保机构银行账号(steps步骤数组，datatable_id往来对象数据源id，zhmc账户名称，khyh开户银行，yhzh银行账号)
  function jy_xzdbjg(steps,datatable_id,zhmc,khyh,yhzh){
    //插入往来单位
    steps.push(  {
      "args": "",
      "datatable_id": datatable_id,
      "field_params": [
        {
          "data_type": 1,
          "field": datatable_id=="1880859224230072320"?"gys":"mc",//判断是否是供应商数据源
          "value": zhmc,
          "value_from": 1
        }
      ],
      "opt_type": 1,
      "step_name": "插入往来单位"
    });
    //插入银行账号
    steps.push(  {
      "args": "",
      "datatable_id": "1880107040475451392",
      "field_params": [
        {
          "data_type": 1,
          "field": "zhmc",
          "value": zhmc,
          "value_from": 1
        },
        {
          "data_type": 1,
          "field": "yh",
          "value": khyh,
          "value_from": 1
        },
        {
          "data_type": 1,
          "field": "yhzh",
          "value": yhzh,
          "value_from": 1
        },
        {
          "data_type": 1,
          "field": "wldw",
          "value": "插入往来单位",
          "value_from": 2
        }
      ],
      "opt_type": 1,
      "step_name": "插入银行账号"
    });
    //更新代收代付往来对象
    steps.push(  {
      "args": "提交表单",
      "args_from": 2,
      "datatable_id": datatable_id=="1880859224230072320"?"1959468120192061440":"1880859101055946752",//如果往来对象数据源是供应商，则更新合作方代收代付，否则更新代收代付
      "field_params": [
        {
          "data_type": 1,
          "field": "wldx",
          "value": "插入往来单位",
          "value_from": 2
        }
      ],
      "opt_type": 4,
      "step_name": "更新代收代付往来对象"
    });
    return steps;
  }
  //获取税押金和税押金id(dom页面控件所在的dom，kjs需要赋值的控件名称{"zkye":XXX,"id":XXX})
  function jy_hqsyj(dom,kjs,xm,gs,bsc,wldx){
    debugger
    const args = {
      "datatable_id": "1914534321918578688",
      "search": "",
      "search_fields": [
        {
          "quick_search": true,
          "field": "zkye",//账款余额
          "table": "a",
          "data_type": 1
        }
      ],
      "advance_filters": {condition: "a.:[xm]=? and a.:[gs]=? and a.:[bsc]=? and a.:[wldx]=? and a.:[zklx]=?", values: JSON.stringify([xm,gs,bsc,wldx,"1885244323826503681"])},
      "order_by": "",
      "group_by": "",
      "where": "",
      "join_tables": "",
      "query_tables": "",
      "page": 1,
      "page_size": 20
    }
    ycWindow.plugins.crud.Query(args, (result) => {
      debugger
      if(result.total){
        if(kjs.zkye){
          dom.getControlByName(kjs.zkye).setValue(result.data[0].zkye);
        }
        if(kjs.id){
          dom.getControlByName(kjs.id).setValue(result.data[0].id);
        }
      }else{
        if(kjs.zkye){
          dom.getControlByName(kjs.zkye).setValue(0);
        }
        if(kjs.id){
          dom.getControlByName(kjs.id).setValue("");
        }
      }
    }, (data) => {
      console.log("查询往来余额失败")
    })
  }
  //获取往来余额账款金额和往来余额id(dom页面控件所在的dom，kjs需要赋值的控件名称{"zkye":XXX,"id":XXX})
  function jy_hqwlye(dom,kjs,xm,gs,bsc,wldx,zklx){
    debugger
    const args = {
      "datatable_id": "1914534321918578688",
      "search": "",
      "search_fields": [
        {
          "quick_search": true,
          "field": "zkye",//账款余额
          "table": "a",
          "data_type": 1
        }
      ],
      "advance_filters": {condition: "a.:[xm]=? and a.:[gs]=? and a.:[bsc]=? and a.:[wldx]=? and a.:[zklx]=?", values: JSON.stringify([xm,gs,bsc,wldx,zklx])},
      "order_by": "",
      "group_by": "",
      "where": "",
      "join_tables": "",
      "query_tables": "",
      "page": 1,
      "page_size": 20
    }
    ycWindow.plugins.crud.Query(args, (result) => {
      debugger
      if(result.total){
        if(kjs.zkye){
          dom.getControlByName(kjs.zkye).setValue(result.data[0].zkye);
        }
        if(kjs.id){
          dom.getControlByName(kjs.id).setValue(result.data[0].id);
        }
      }else{
        if(kjs.zkye){
          dom.getControlByName(kjs.zkye).setValue(0);
        }
        if(kjs.id){
          dom.getControlByName(kjs.id).setValue("");
        }
      }
    }, (data) => {
      console.log("查询往来余额失败")
    })
  }
  //修改税押金(wlyeid往来余额id)
  function jy_xgsyj(steps,wlyeid,jobname,xm,gs,bsc,wldx,wllx,je){
    debugger
    //如果有往来余额id，则修改往来余额，没有则创建往来余额
    if(wlyeid){
      //查询往来对象金额
      var rw1={
        "step_name": "查询往来对象金额_"+jobname,
        "opt_type": 5,
        "query_args": {
          "datatable_id": "1914534321918578688",
          "search_fields": [
            {
              "field": "cast((a.:[zkye] + ("+je+")) as decimal(12,2)) as bghye",
              "table": "a",
              "data_type": 11
            }
          ],
          "advance_filters": {
            "condition": "a.id=?",
            "values": JSON.stringify([wlyeid])
          }
        },
        "query_into": "往来对象金额_"+jobname
      };
      steps.push(rw1);
      //更新往来对象金额
      var rw2={
        "step_name": "更新往来对象金额_"+jobname,
        "opt_type": 4,
        "datatable_id": "1914534321918578688",
        "args": "往来对象金额_"+jobname+".id",
        "args_from": 3,
        "field_params": [
          {
            "value_from": 3,
            "field": "zkye",
            "value": "往来对象金额_"+jobname+".bghye",
            "data_type": 1
          },
          {
              "value_from": 1,
              "field": "rld",
              "value": "",
              "data_type": 1
            }
        ]
      };
      steps.push(rw2);
    }else{
      steps.push({
        "step_name": "插入往来余额_"+jobname,
        "opt_type": 1,
        "datatable_id": "1914534321918578688",
        "args": "",
        "field_params": [{
            "value_from": 1,
            "field": "xm",
            "value": xm,
            "data_type": 1
          },{
            "value_from": 1,
            "field": "gs",
            "value": gs,
            "data_type": 1
          },{
            "value_from": 1,
            "field": "bsc",
            "value": bsc,
            "data_type": 1
          },{
            "value_from": 1,
            "field": "wldx",
            "value": wldx,
            "data_type": 1
          },{
            "value_from": 1,
            "field": "zklx",
            "value": "1885244323826503681",
            "data_type": 1
          },{
            "value_from": 1,
            "field": "zkye",
            "value": je,
            "data_type": 1
          },{
            "value_from": 1,
            "field": "wllx",
            "value": wllx,
            "data_type": 1
          }]
      })
    }
    return steps;
  }
  //修改往来余额(wlyeid往来余额id)
  function jy_xgwlye(steps,wlyeid,jobname,xm,gs,bsc,wldx,wllx,je,zklx){
    debugger
    //如果有往来余额id，则修改往来余额，没有则创建往来余额
    if(wlyeid){
      //查询往来对象金额
      var rw1={
        "step_name": "查询往来对象金额_"+jobname,
        "opt_type": 5,
        "query_args": {
          "datatable_id": "1914534321918578688",
          "search_fields": [
            {
              "field": "cast((a.:[zkye] + ("+je+")) as decimal(12,2)) as bghye",
              "table": "a",
              "data_type": 11
            }
          ],
          "advance_filters": {
            "condition": "a.id=?",
            "values": JSON.stringify([wlyeid])
          }
        },
        "query_into": "往来对象金额_"+jobname
      };
      steps.push(rw1);
      //更新往来对象金额
      var rw2={
        "step_name": "更新往来对象金额_"+jobname,
        "opt_type": 4,
        "datatable_id": "1914534321918578688",
        "args": "往来对象金额_"+jobname+".id",
        "args_from": 3,
        "field_params": [
          {
            "value_from": 3,
            "field": "zkye",
            "value": "往来对象金额_"+jobname+".bghye",
            "data_type": 1
          },
          {
              "value_from": 1,
              "field": "rld",
              "value": "",
              "data_type": 1
            }
        ]
      };
      steps.push(rw2);
    }else{
      steps.push({
        "step_name": "插入往来余额_"+jobname,
        "opt_type": 1,
        "datatable_id": "1914534321918578688",
        "args": "",
        "field_params": [{
            "value_from": 1,
            "field": "xm",
            "value": xm,
            "data_type": 1
          },{
            "value_from": 1,
            "field": "gs",
            "value": gs,
            "data_type": 1
          },{
            "value_from": 1,
            "field": "bsc",
            "value": bsc,
            "data_type": 1
          },{
            "value_from": 1,
            "field": "wldx",
            "value": wldx,
            "data_type": 1
          },{
            "value_from": 1,
            "field": "zklx",
            "value": zklx,
            "data_type": 1
          },{
            "value_from": 1,
            "field": "zkye",
            "value": je,
            "data_type": 1
          },{
            "value_from": 1,
            "field": "wllx",
            "value": wllx,
            "data_type": 1
          }]
      })
    }
    return steps;
  }
  //外部钱包支付(amount金额，customerId用户id，description描述，detailType明细类型，outTradeNo单据id)
  function jy_wbqbzf(amount,customerId,description,detailType,outTradeNo,originalOutTradeNo,func){
    ycWindow.plugins.YHQB.Pay({
      "amount": amount, //金额
      "customerId": customerId, //客户id
      "description": description, //描述
      "detailType": detailType, //明细类型
      "outTradeNo": outTradeNo, //第三方交易号
      "originalOutTradeNo":originalOutTradeNo
      }, func, ()=>{
          console.log("失败")
    })
  }
  //银企支付
  function jy_yqzf(amount,outTradeNo,remark,revAccountName,revAccountNo,revOpenBankName,serviceCode,serviceType,description,func){
    ycWindow.plugins.YHQB.YQPay({
      "amount": amount,//金额
      "outTradeNo": outTradeNo,//交易号
      "remark": remark,//说明
      "revAccountName": revAccountName,//接受方名
      "revAccountNo": revAccountNo,//接受方账号
      "revOpenBankName": revOpenBankName,//接受方银行账号
      "serviceCode": serviceCode,//服务号编码
      "serviceType": serviceType,//服务类类型
      "description":description//描述
    }, func, ()=>{
        console.log("失败")
    })
  }